package array.medium;

import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;

public class SearchA2DMatrixII_240 {

    public boolean searchMatrix(int[][] matrix, int target) {
        for (int[] ints : matrix) {
            int l = 0, r = ints.length - 1;
            while (l < r) {
                int mid = l  + (r + 1) >> 1;
                if (ints[mid] <= target) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            if (ints[r] == target) return true;
        }
        return false;
    }

    public static void main(String[] args) {
        SearchA2DMatrixII_240 sac = new SearchA2DMatrixII_240();
        System.out.println(sac.searchMatrix(new int[][]{{-5}}, -5));

    }
}
